plot_functions module

Module that contains functionality to plot some properties of (binary) systems.

Different routines are defined here to plot orbits, masses, angular momenta etc.

Structure of file:

custom logging strings parsing functions plotting functions master function: plot_system

All the loose components here can of course be used in other routines if you want.

There is no pre loaded matplotlib rc, you should do that yourself

These plotting routines are designed for binary systems, and admittedly they are here mostly for inspirational purposes, since one would probably want to customise the plots. Regardless, having some plotting routines in here seemed like a nice idea

Tasks

TODO: This module is not finished yet. TODO: Make modules for single system TODO: Put all the plotting functions in here

binarycpython.utils.plot_functions.color_by_index(row, column, colors)[source]

Function that returns a color based on row and column information. Used to color the stellar types

binarycpython.utils.plot_functions.dummy()[source]

Placeholder function

binarycpython.utils.plot_functions.parse_function_hr_diagram(output)[source]

Parsing function for the HR plotting routine

Parameters

output (str) – raw binary_c output string

Returns

pandas dataframe containing the columns for the HR diagram plotting routine

binarycpython.utils.plot_functions.parse_function_masses(output)[source]

Parsing function for the orbit plotting routine

Parameters

output (str) – raw binary_c output string

Returns

pandas dataframe containing the columns for the masses plotting routine

binarycpython.utils.plot_functions.parse_function_orbit(output)[source]

Parsing function for the orbit plotting routine

Parameters

output (str) – raw binary_c output string

Returns

pandas dataframe containing the columns for the orbit plotting routine

binarycpython.utils.plot_functions.plot_HR_diagram(df, show_stellar_types=False, show_plot=True, use_astropy_values=True)[source]

Function to plot the HR diagram evolution of the system. Assumes its a binary system.

For a single star see plot_HR_diagram_single

Plot shows Log luminosity on y axis, log temperature on x axis (reversed)

requires:
  • time

  • stellar_type_1

  • stellar_type_2

  • radius_1

  • radius_2

  • luminosity_1

  • luminosity_2

Plots:
  • luminosity_1 vs teff_1

  • luminosity_2 vs teff_2

Tasks:
  • TODO: add HD limit

  • TODO: add lines of constant radius

Parameters
  • df – pandas dataframe with the required columns

  • show_stellar_types (bool) – whether to color code the tracks and show the stellar types

  • show_plot (bool) – whether to actually show the plot. If false: returns the figure object

  • use_astropy_values (bool) – Whether to use astropy values for for Rsun, Lsun and stefan boltzman constant.

Returns

returns a figure object if show_plot is false

binarycpython.utils.plot_functions.plot_masses(df, show_stellar_types=False, show_plot=True)[source]

Function to plot the masses of the system.

Function requires the following keys:
  • time

  • pms_mass_1

  • pms_mass_2

  • mass_1

  • mass_2

Plots the following quantities:
  • Total mass

  • Mass star 1

  • Mass star 2

  • Pms mass 1

  • pms mass 2

  • pms total mass

  • (maybe?) core and env masses

TODO: fix stellar_types plot

Parameters
  • df – pandas dataframe with the required columns

  • show_stellar_types (bool) – whether to color code the tracks and show the stellar types

  • show_plot (bool) – whether to actually show the plot. If false: returns the figure object

Returns

returns a figure object if show_plot is false

binarycpython.utils.plot_functions.plot_orbit(df, show_stellar_types=False, show_plot=True)[source]

Function to plot the orbital elements of the system

Plots the following quantities:
  • Orbital period

  • Separation

  • eccentricity

TODO: fix stellar_types plot

Parameters
  • df – pandas dataframe with the required columns

  • show_stellar_types (bool) – whether to color code the tracks and show the stellar types

  • show_plot (bool) – whether to actually show the plot. If false: returns the figure object

Returns

returns a figure object if show_plot is false

binarycpython.utils.plot_functions.plot_system(plot_type, **kwargs)[source]

Function to plot the different quantities of a system.

This goes (in general) via the following steps:
  • a preset custom logging for a specific plotting routine is loaded, depending on the choice of plot_type

  • This is used for the run_system call

  • The output of this run_system is loaded into a dataframe by

    parsing it with a corresponding parsing function

  • The dataframe is passed to the plotting routine

  • plot is shown or returned.

There are several pre-set plots to choose from:
  • mass_evolution

  • orbit_evolution

  • hr_diagram

All keywords are considered kwargs, except for plot_type

Parameters
  • plot_type – string input should be one of [‘mass_evolution’, ‘orbit_evolution’, ‘hr_diagram’]. Input will be matched against this, and then go through a dictionary to pick the correct plotting function.

  • show_plot – boolean whether to show the plot. If False it returns the figure object (makes so that you can customize it)

  • show_stellar_types – whether to plot the stellar type evolution on a second pane. This is not included in all the plotting routines.

  • input (Other) – other kwargs that are passed to run_system (inspect the docstring of run_system for more info)

Returns

returns a object figure if show_plot = false